package com.wn.aop.annotation;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @FileName: ExampleAspect
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2020/7/17 - 15:38
 * @Version: V1.0
 * @Company: 东方微银科技（北京）有限公司
 */
@Aspect
@Component
public class ExampleAspect {

    @Pointcut("execution(public void com.wn.aop.annotation.Example.show())")
    public void pointcut() {
    }

    @Before("pointcut()")
    public void before() {
        System.out.println("before..........");
    }

    @After("pointcut()")
    public void after() {
        System.out.println("after..........");

    }

    @AfterReturning("pointcut()")
    public void afterReturn() {
        System.out.println("afterReturn..........");

    }

    @AfterThrowing("pointcut()")
    public void afterThrowing() {
        System.out.println("afterThrowing..........");

    }

    @Around("pointcut()")
    public void around(ProceedingJoinPoint joinPoint) {
        try {
            System.out.println("around start..........");
            joinPoint.proceed();
            System.out.println("around end..........");
        } catch (Throwable e) {
            e.printStackTrace();
        }

    }
}
